From a97d5a060a534a3c658578e7f14ab43556db93ca Mon Sep 17 00:00:00 2001
From: Fabrice Fontaine <fontaine.fabrice@gmail.com>
Date: Thu, 30 Dec 2021 16:19:46 +0100
Subject: [PATCH] Support glibmm 2.68

Support glibmm 2.68 which has been released one year ago and is the
first stable release in the glibmm-2.68 ABI series:
https://gitlab.gnome.org/GNOME/glibmm/-/blob/2.68.2/NEWS

C++17 support is mandatory with glibmm 2.68

Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
[Upstream status: not sent yet]
---
 CMakeLists.txt | 23 +++++++++++++++++++----
 INSTALL        |  2 +-
 2 files changed, 20 insertions(+), 5 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 7791b1b1..58a9cf92 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -75,7 +75,14 @@ add_subdirectory(manual)
 #-------------------------------------------------------------------------------
 
 list(APPEND PKGDEPS glib-2.0>=2.28.0)
-list(APPEND PKGDEPS glibmm-2.4>=2.28.0)
+
+set(LIBSR_GLIBMM "glibmm-2.4>=2.28.0")
+find_package(PkgConfig)
+pkg_check_modules(LIBSRGLIBMM24 ${LIBSR_GLIBMM})
+if(NOT LIBSRGLIBMM24_FOUND)
+	set(LIBSR_GLIBMM "glibmm-2.68>=2.68.0")
+endif()
+list(APPEND PKGDEPS ${LIBSR_GLIBMM})
 
 if(ENABLE_FLOW)
 	list(APPEND PKGDEPS gstreamermm-1.0>=1.8.0)
@@ -93,7 +100,6 @@ if(ANDROID)
 	list(APPEND PKGDEPS libsigrokandroidutils>=0.1.0)
 endif()
 
-find_package(PkgConfig)
 pkg_check_modules(LIBSRCXX ${LIBSR_CXX_BINDING})
 if(NOT LIBSRCXX_FOUND OR NOT LIBSRCXX_VERSION)
 	message(FATAL_ERROR "libsigrok C++ bindings missing, check libsigrok's 'configure' output (missing dependencies?)")
@@ -225,7 +231,11 @@ memaccess_check_unaligned_le(HAVE_UNALIGNED_LITTLE_ENDIAN_ACCESS)
 set(PV_TITLE PulseView)
 set(PV_VERSION_STRING "0.5.0")
 
-set(PV_GLIBMM_VERSION ${PKGDEPS_glibmm-2.4_VERSION})
+if(LIBSRGLIBMM24_FOUND)
+	set(PV_GLIBMM_VERSION ${PKGDEPS_glibmm-2.4_VERSION})
+else()
+	set(PV_GLIBMM_VERSION ${PKGDEPS_glibmm-2.68_VERSION})
+endif()
 
 include(GetGitRevisionDescription)
 
@@ -486,7 +496,12 @@ qt5_add_resources(pulseview_RESOURCES_RCC ${CMAKE_BINARY_DIR}/translations.qrc)
 add_definitions(-DQT_NO_KEYWORDS)
 add_definitions(-D__STDC_LIMIT_MACROS)
 add_definitions(-Wall -Wextra)
-add_definitions(-std=c++11)
+if(LIBSRGLIBMM24_FOUND)
+	add_definitions(-std=c++11)
+else()
+	# glibmm-2.68 reuires c++17
+	add_definitions(-std=c++17)
+endif()
 add_definitions(-DBOOST_MATH_DISABLE_FLOAT128=1)
 if(WIN32)
 	add_definitions(-Wa,-mbig-obj -O3)
diff --git a/INSTALL b/INSTALL
index da89be8d..8003fcfb 100644
--- a/INSTALL
+++ b/INSTALL
@@ -14,7 +14,7 @@ Requirements
  - pkg-config >= 0.22
  - cmake >= 2.8.12
  - libglib >= 2.28.0
- - glibmm-2.4 (>= 2.28.0)
+ - glibmm-2.4 (>= 2.28.0) or glibmm-2.68 (>= 2.68.0)
  - Qt5 (>= 5.3), including the following components:
     - Qt5Core, Qt5Gui, Qt5Widgets, Qt5Svg, Qt5LinguistTools
     - Qt translation package (optional; needed at runtime, not build time)
-- 
2.34.1

